<?php

/**
 * AlbumController
 * 
 * @author
 * @version 
 */

require_once 'Zend/Controller/Action.php';

class AlbumController extends Zend_Controller_Action {
	
	protected $_id;
	protected $_src;
	protected $_album;
	public function init()
	{
		$this->_id = (int) $this->_getParam('id',null);
		$this->_src =  $this->_src  = $this->getRequest()->getPost('src');
		$this->_album = ZloY_Album::create($this->_id, $this->_getParam('item'));
	}
	
	public function indexAction() {
			
	}
	
	public function uploadAction()
	{
		Zend_Layout::getMvcInstance()->disableLayout();

		if($this->_getParam('main', false))
		{
			$image = $this->_album->upload();
			$this->_album->setMainImage($image);
			echo $this->_album->getMainImage('s');
		} else {
			$image = $this->_album->upload();
			echo $image;
		}
		
	}
	
	public function deleteAction()
	{
		Zend_Layout::getMvcInstance()->disableLayout();
		Zend_Debug::dump($this->_src);
		$this->_album->delete($this->_src);
	}
}